package com.dht.xiao.jianye.adapter;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.dht.xiao.jianye.R;
import com.dht.xiao.jianye.bean.OrderDetailsBean;

import cn.dlc.commonlibrary.ui.adapter.BaseRecyclerAdapter;

/**
 * 订单结果
 */
public class OrderAdapter extends BaseRecyclerAdapter<OrderDetailsBean.DataBean> {
    Context context;
    @Override
    public int getItemLayoutId(int viewType) {
        return R.layout.item_order;
    }

    public OrderAdapter(Context context) {
        this.context = context;
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onBindViewHolder(CommonHolder holder, int position) {

       // holder.getImage(R.id.image).setBackgroundResource(getItem(position).image);
        Glide.with(context).load(getItem(position).image_mini).apply(new RequestOptions().
                diskCacheStrategy(DiskCacheStrategy.RESOURCE).error(R.mipmap.btn_blue_nor)).into(holder.getImage(R.id.image));

        holder.getText(R.id.name).setText(getItem(position).name);
        if (getItem(position).box .equals("0")) {
            holder.getText(R.id.weight).setText((int)getItem(position).weight + "个");
        }else {
            holder.getText(R.id.weight).setText(getItem(position).weight + "公斤");
        }
        holder.getText(R.id.price).setText(getItem(position).price+"");
       // holder.getText(R.id.name).setText(getItem(position).name);
    }
}
